<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="uname"><br><br>

      <label>年龄：</label>
      <input type="number" v-model="age"><br><br>

      <label>身高：</label>
      <input type="number" v-model="height">(米)<br><br>

      <label>体重：</label>
      <input type="number" v-model="weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model="illness"><br><br>

      <button @click="getBMI">诊断</button>
    </form>

    <p v-text="health"></p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      uname:'',
      age:'',
      height:'',
      weight:'',
      illness:'',
      health:''
    }
  },
  methods: {
    getBMI(){
     const bmi = this.weight / Math.pow(this.height,2)
     if(bmi >= 18.5 && bmi <= 23.9){
      this.health = `患者${this.uname}的诊断结果 健康`
     } else{
      this.health = `患者${this.uname}的诊断结果 不健康`
     }
    }
  }
}
</script>